package Hxw3DEngine.core.display
{
	import Hxw3DEngine.core.component.renderer.MeshRenderer;
	import Hxw3DEngine.core.materials.Material3D;
	import Hxw3DEngine.core.Resource.geometry.ResourceGeometry;
	import Hxw3DEngine.asset.parsers.bson.vo.Stream;
	
	public class Panel3D extends GameObject
	{
		
		private var _sceleUV:Number = 1;
		
		private var width:Number = 100;
		
		private var height:Number = 100;
		
		public function set sceleUV(val:Number):void{
			_sceleUV = val;
		}
		
		public function Panel3D(_materials:Material3D , w:Number = 100,h:Number = 1000,_sceleUv:Number = 10)
		{
			width = w;height = h;sceleUV = _sceleUv;
			
			var vertexdata:Vector.<Number> = Vector.<Number>([
				//x,y,z,u,v
				-width,0,height,
				width,0,height,
				-width,0,-height,
				width,0,-height
				
			]);
			
			var uvdata:Vector.<Number> = Vector.<Number>([
				0,0,
				0,_sceleUV,
				_sceleUV,0,
				_sceleUV,_sceleUV
			]);
			
			
			var indexdata:Vector.<uint> = Vector.<uint>([
				0,1,2,1,3,2
			]);
			
			var mesh:MeshRenderer = new MeshRenderer;
			addComponent(mesh);
			mesh.geometry = new ResourceGeometry;
			mesh.geometry.createFromStreams(indexdata, 4, [
					Stream.fromVector(Stream.stream_positions, vertexdata),
					Stream.fromVector(Stream.stream_uvs_1, uvdata)
				]);
			mesh.material = _materials;
		}
		
	}
}